<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class AssuntoController extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct()
        {	parent::__construct();
            $this->load->model('indexModel');
            $this->load->model('AssuntoModel');
	} 
	public function index()
	{
		$dados = array(
                'titulo' => 'Index',
                'pagina' => 'principal',
            	//'conta' => $this->PrincipalModel->buscaPai()->result(),
            	'materia' => $this->indexModel->buscaMateriaCategoria(1,3,2)->result(),
            	'materiaB' => $this->indexModel->buscaMateriaCategoria(2,3,2)->result(),
            	'materiaP' => $this->indexModel->buscaMateriaCategoria(3,3,2)->result(),
            	'materiaG' => $this->indexModel->buscaMateriaCategoria(6,3,0)->result(),
            	'materiaG2' => $this->indexModel->buscaMateriaCategoria(6,3,3)->result(),
            	'materiaMundo' => $this->indexModel->buscaMateriaCategoria(1,1,1)->row(),
            	'materiaBrasil' => $this->indexModel->buscaMateriaCategoria(2,1,1)->row(),
            	'materiaParaiba' => $this->indexModel->buscaMateriaCategoria(3,1,1)->row(),
            	'materiaEntenda' => $this->indexModel->buscaMateriaCategoria(11,1,1)->row(),
            	'materiaCuriosidade' => $this->indexModel->buscaMateriaCategoria(12,1,1)->row(),
            	'imagemCarrossel' => $this->indexModel->buscaImagemCarrossel()->result(),
            	'maisAcessado' => $this->indexModel->buscaMaisAcessado()->result(),
            	'tag' => $this->indexModel->buscaTags()->result(),
            	'evento'=>$this->indexModel->buscaMateriaCategoria(28,5,0)->result(),
            	'especial' => $this->indexModel->buscaMateriaCategoria(29,1,0)->row(),
            	
            );		 
            $this->load->view('indexView',$dados);		
        
	}
	
	
	public function buscaAssunto() 
	{       $dados = array(
                'titulo' => 'Assunto',
                'pagina' => 'assunto',               
                //'conteudoAssunto' => $this->AssuntoModel->buscaateriaCategoria(29,1,0)->row()
            );		 
            $this->load->view('indexView',$dados);	
	}
        public function adicionarComentario()
        {   $this->form_validation->set_rules('nome','NOME','required|trim');
            $this->form_validation->set_rules('email','EMAIL','required|trim|email');
            $this->form_validation->set_rules('mensagem','MENSAGEM','required|trim|min_length[10]|max_length[100]');
            $this->form_validation->set_rules('captchaOriginal', 'IMAGEM');
            $this->form_validation->set_rules('captcha', 'SEQUÊNCIA', 'required|matches[captchaOriginal]');
           
            if($this->form_validation->run()== TRUE):
                $dados = elements(array('cod_pagina','nome','email','mensagem','data_comentario'),$this->input->post());
                $this->AssuntoModel->insereComentario($dados);
             endif;
             $dados = array(
                  'titulo' => 'Assunto',
                  'pagina' => 'assunto',
             );
             $this->load->view('indexView',$dados);		
         }

	

}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */